package com.inet.test02;


import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author weijingchen
 * @Date 2025/6/26 14:47
 * @Version 1.0.0
 */
public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10201);
        Socket accept = serverSocket.accept();
        System.out.println("连接成功");


        InputStream is = accept.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);

        int read;
        while ((read = br.read()) != -1) {
            System.out.print((char)read);
        }

        //回写数据
        OutputStream os = accept.getOutputStream();
        os.write("hello client".getBytes());


        accept.close();
        serverSocket.close();
    }
}
